#!/bin/bash
# Radio Swiss Jazz-Playlist
# $1 = outfile

### Variabel
Name="Radio Swiss Jazz [www.radioswissjazz.ch]"
### 

# get...
wget -q --tries=2 --timeout=5 -O /tmp/playlist "http://www.radioswissjazz.ch/cgi-bin/pip/html.cgi?m=playlist&lang=de&v=d&loaded=#onair"

# Artist/Title
all=`grep -A5 'class="on"' /tmp/playlist`
title=${all/*$';">'/}; title=${title/$'<'\/'strong>'*/}
artist=${all/*$'strong><br '\/'>'/}; artist=${artist/$'<'\/'a><'\/'td>'*/}
# temp. no Info
artist=${artist:='---'}; titel=${title:='---'}

# write...
if [ $1 ]; then
	echo $Name    > $1
	echo $artist >> $1
	echo $title  >> $1
else
	echo "$Name: Interpret/Titel =  $artist / $title"
fi
